<?php


namespace app\admin\service;


use app\admin\model\Applet;

use app\admin\model\Scale;
use think\facade\Db;

class ScaleService extends BaseService
{
    /**
     * 构造函数
     * @author 牧羊人
     * @since 2020/11/15
     * AdSortService constructor.
     */
    public function __construct()
    {
        $this->model = new Scale();
    }

    public function getUserInfo()
    {
        $info = Db::name('mimi_fees')->where('id', '=', 1)->find();

        if (!$info) {
            $info['type'] = 0;
        }
        return message("操作成功", true, $info);
    }

    public function updateUserInfo()
    {

        // 参数
        $param = request()->param();
        $data = array(
            'type' => $param['type'],
            'corporation' => isset($param['corporation']) ? $param['corporation'] : '0',
            'yi_price' => isset($param['yi_price']) ? $param['yi_price'] : 0,
            'er_price' => isset($param['er_price']) ? $param['er_price'] : 0,
            'sn_price' => isset($param['sn_price']) ? $param['sn_price'] : 0,
            'qu_price' => isset($param['qu_price']) ? $param['qu_price'] : 0,
            'li_corporation' => isset($param['li_corporation']) ? $param['li_corporation'] : 0,
            'li_yi_price' => isset($param['li_yi_price']) ? $param['li_yi_price'] : 0,
            'li_er_price' => isset($param['li_er_price']) ? $param['li_er_price'] : 0,
            'li_sn_price' => isset($param['li_sn_price']) ? $param['li_sn_price'] : 0,
            'li_qu_price' => isset($param['li_qu_price']) ? $param['li_qu_price'] : 0,
            'zi_corporation' => isset($param['zi_corporation']) ? $param['zi_corporation'] : 0,
            'zi_yi_price' => isset($param['zi_yi_price']) ? $param['zi_yi_price'] : 0,
            'zi_er_price' => isset($param['zi_er_price']) ? $param['zi_er_price'] : 0,
            'zi_sn_price' => isset($param['zi_sn_price']) ? $param['zi_sn_price'] : 0,
            'zi_qu_price' => isset($param['zi_qu_price']) ? $param['zi_qu_price'] : 0,
            'w_corporation' => isset($param['w_corporation']) ? $param['w_corporation'] : 0,
            'w_yu_price' => isset($param['w_yu_price']) ? $param['w_yu_price'] : 0,
            'fees' => isset($param['fees']) ? $param['fees'] : 0,
            'id' => 1,

        );

        $result = $this->model->edit($data);
        if (!$result) {
            return message("更新资料信息失败", false);
        }
        return message("更新资料信息成功");
    }
}